package com.jet.summary.controller;

import com.jet.summary.domain.dto.SummaryCommissionDto;
import com.jet.summary.domain.query.SummaryCommissionListQuery;
import com.jet.summary.domain.query.SummaryCommissionQuery;
import com.jet.summary.domain.vo.SummaryCommissionVo;
import com.jet.core.model.vo.PageVo;
import com.jet.core.result.ResultJson;
import com.jet.summary.service.SummaryCommissionService;
import org.springframework.web.bind.annotation.*;

/**
 * @author dcl
 * @since 2024/4/8 10:17
 */
@RestController
@RequestMapping(value = {"/clerk/commission", "summary-commission"})
public class SummaryCommissionController {

    private final SummaryCommissionService summaryCommissionService;

    public SummaryCommissionController(SummaryCommissionService summaryCommissionService) {
        this.summaryCommissionService = summaryCommissionService;
    }

    /**
     * 手动计算员工提成
     *
     * @param merchantNo
     * @param storeNo
     * @param accountId
     * @param dto
     * @return
     */
    @PutMapping("/summary")
    public ResultJson<Void> summary(@RequestHeader long merchantNo,
                                    @RequestHeader long storeNo,
                                    @RequestHeader String accountId,
                                    @RequestBody SummaryCommissionDto dto) {
        summaryCommissionService.summaryReuse(merchantNo, dto);
        return ResultJson.ok();
    }

    @GetMapping("/page")
    public ResultJson<PageVo<SummaryCommissionVo>> page(@RequestHeader long merchantNo,
                                                        @RequestHeader long storeNo,
                                                        @RequestHeader String accountId,
                                                        SummaryCommissionQuery query) {
        PageVo<SummaryCommissionVo> pageVo = summaryCommissionService.page(merchantNo, storeNo, accountId, query);
        return ResultJson.ok(pageVo);
    }
}
